import request from "@/utils/request";

enum API {
  //获取全部菜单与按钮的标识数据
  ALLPERMISSTION_URL = '/admin/acl/permission',
  //给某一级菜单新增一个子菜单
  ADDMENU_URL = '/admin/acl/permission/save',
  //更新某一个已有的菜单
  UPDATE_URL = '/admin/acl/permission/update',
  //删除已有的菜单
  DELETEMENU_URL = '/admin/acl/permission/remove/',
}

// 获取全部菜单与按钮标识的数据
export const getAllPermissionAPI = () => request.get(API.ALLPERMISSTION_URL)

// 更新菜单或者添加一个新菜单
export const addOrUpdateMenu = (data: any) => {
  if (data.id) {
    // 如果当前携带的参数中包含id，那么表明是修改菜单
    return request.put(API.UPDATE_URL, data)
  } else {
    return request.post(API.ADDMENU_URL, data)
  }
}
// 删除已有的菜单
export const removeMenu = (id: number) => request.delete(API.DELETEMENU_URL + id)